﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Domep.Server.Kernel.DBCommunication;
using Domep.Server.Kernel;
using Domep.Server.Kernel.ApplianceCommunication;

namespace Domep.Server.API
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class OrderManager : IOrderManager
    {
        OrderChecker orderChecker;
        ApplianceFunctionalityLauncher launcher;
        
        #region IOrderManager Members

        public void sendOrder(int functionalityId, int applianceId)
        {
            orderChecker = new OrderChecker();
            try
            {
                OrderInfo orderInfo = orderChecker.CheckCompatibility(functionalityId, applianceId);
                launcher = new ApplianceFunctionalityLauncher();
                launcher.Launch(orderInfo);
            }
            catch (InvalidFunctionalityException ife)
            {
                throw ife;
            }
            catch (ApplianceCommunicationException ace)
            {
                throw ace;
            }
        }

        #endregion
    }
}
